package main;

import java.util.Vector;

import myEddy.tuple.Tuple;

public class Gen_Aleatoire extends Thread {

	Vector coloms;
	String table;
	int debit;
	Tuple T2,T1;
	int flux;
	int inc=1;
	boolean stop=false;
	
	public Gen_Aleatoire(Vector coloms_1, String table, int debit, int flux) {
		this.coloms=coloms_1;
		this.table=table;
		this.debit=debit;
		this.flux=flux;
		
		
	}

	@Override
	public void run() {
		
		while(stop==false){
			
			  try {
     	inc++;  
//int nombreAleatoire=0;
String lister="";
		
String valeur1=(String)coloms.elementAt(0)+""+inc;
     	
     		T1 = new Tuple(table);
        lister = "";
        T1.addElement((String) coloms.elementAt(0),valeur1);
		lister=(lister+valeur1+",{ "+coloms.elementAt(0)+"}");
         	for(int i=1;i<coloms.size();i++){
         		//nombreAleatoire = 1 + (int)(Math.random() * ((10 - 1) + 1));
         		
         		String valeur=	generate(3);
    		T1.addElement((String) coloms.elementAt(i),valeur);
    		lister=(lister+valeur+",{ "+coloms.elementAt(i)+"}");
         	}
     		fram.AddT(T1);
     		fram.list1.add(lister);
     		fram.liste2.add("flux"+flux);
	      
		Gen_Aleatoire.sleep(debit);
	} catch (InterruptedException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
		
	}
		
	}
	public static String generate(int length) {
        String chars = "abcwetulnqiop10"; 
        StringBuffer pass = new StringBuffer();
        for(int x=0;x<length;x++)   {
           int i = (int)Math.floor(Math.random() * (chars.length() -1));
           pass.append(chars.charAt(i));
        }
        return pass.toString();
}
}
